package com.shopnight.utils;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

//用来获取spring boot的工程
@Component
public class AppcationContextUtil implements ApplicationContextAware{

	private  static ApplicationContext applicationContext;
	
	@Override
	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
		this.applicationContext = applicationContext;
	}

	//提供工厂中获取对象的方法
	public static Object getBean(String beanName) {
         return applicationContext.getBean(beanName);
	}
}
